<?php

/**
 * This is the model class for table "order_history".
 *
 * The followings are the available columns in table 'order_history':
 * @property string $order_history_id
 * @property string $order_id
 * @property string $user_id
 * @property string $owner_id
 * @property string $website
 * @property string $username
 * @property double $amount
 * @property string $note
 * @property integer $created
 */
class OrderHistory extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return OrderHistory the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'order_history';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('order_id, user_id, owner_id, website, adv_id, website_id, amount, adddate', 'required'),
			array('adv_id, website_id, verify_status', 'numerical', 'integerOnly'=>true),
			array('amount', 'numerical'),
			array('order_id, user_id, owner_id', 'length', 'max'=>10),
			array('website, username', 'length', 'max'=>50),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('order_history_id, order_id, user_id, owner_id, website, username, amount, note, adddate', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'order_history_id' => 'Order History',
			'order_id' => 'Order',
			'user_id' => 'User',
			'owner_id' => 'Owner ID',
			'verify_status' => 'Verify Status',
			'adddate' => 'Date',
			'verifydate' => 'Verify Date',
			'adv_id' => 'Adv',
			'website' => 'Website',
			'website_id' => 'Website ID',
			'username' => 'Username',
			'amount' => 'Amount',
			'note' => 'Note',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('order_history_id',$this->order_history_id,true);
		$criteria->compare('order_id',$this->order_id,true);
		$criteria->compare('user_id',$this->user_id,true);
		$criteria->compare('owner_id',$this->owner_id,true);
		$criteria->compare('website',$this->website,true);
		$criteria->compare('website_id',$this->website,true);
		$criteria->compare('adddate',$this->adddate,true);
		$criteria->compare('verifydate',$this->verifydate,true);
		$criteria->compare('adv_id',$this->adv_id,true);
		$criteria->compare('verify_status',$this->verify_status,true);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('amount',$this->amount);
		$criteria->compare('note',$this->note,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}